package com.sc.nft.dto;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sc.nft.entity.UserEcologyHatchRecords;
import com.sc.nft.entity.vo.EcologySmeltVO;
import com.sc.nft.entity.vo.PageHatchRecordsVO;
import com.sc.nft.entity.vo.ecology.*;
import com.sc.nft.enums.EcologyHatchDirectThrustIncomeType;
import com.sc.nft.enums.UserEcologyHatchRecordsStatus;
import com.sc.nft.mapper.UserEcologyHatchRecordsMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;
import java.util.*;

/**
 * 生态-孵化-用户记录表(sc_user_ecology_hatch_records)数据DAO
 *
 * @author Sun
 * @description 由 Mybatisplus Code Generator 创建
 * @since 2023-10-13 17:22:12
 */
@Slf4j
@Repository
public class UserEcologyHatchRecordsDao extends ServiceImpl<UserEcologyHatchRecordsMapper, UserEcologyHatchRecords> {

    public Integer getStatusCountByEcologyHatchId(Long ecologyHatchId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getEcologyHatchId, ecologyHatchId);
        return count(wrapper);
    }

    public BigDecimal getSumEcologyPointsByUserId(Long userId) {
        return baseMapper.getSumEcologyPointsByUserId(userId);
    }

    public Page<PageHatchRecordsVO> pageHatchRecords(Integer pageNo, Integer pageSize, Long userId) {
        return baseMapper.pageHatchRecords(new Page<>(pageNo, pageSize), userId);
    }

    public Page<JunioRecologyHatchRecords> getJunioRecologyHatchRecordsByUserId(Integer pageNo, Integer pageSize, List<Long> ids) {
        return baseMapper.getJunioRecologyHatchRecordsByUserId(new Page<>(pageNo, pageSize), ids);
    }

    public List<UserEcologyHatchRecords> getSettleList() {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getStatus, UserEcologyHatchRecordsStatus.UNDER_WAY);
        return list(wrapper);
    }

    public List<UserEcologyHatchRecords> getSettleListByEcologyHatchId(Long ecologyHatchId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getEcologyHatchId, ecologyHatchId);
        wrapper.eq(UserEcologyHatchRecords::getStatus, UserEcologyHatchRecordsStatus.UNDER_WAY);
        return list(wrapper);
    }


    public Boolean addAlreadyDayByStatusById(Long id) {
        LambdaUpdateWrapper<UserEcologyHatchRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getStatus, UserEcologyHatchRecordsStatus.UNDER_WAY);
        wrapper.eq(UserEcologyHatchRecords::getId, id);
        wrapper.setSql("already_day = already_day + 1");
        return update(wrapper);
    }


    public boolean updateIsSettleDirectThrustIncomeById(Long id, EcologyHatchDirectThrustIncomeType ecologyHatchDirectThrustIncomeType) {
        LambdaUpdateWrapper<UserEcologyHatchRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getId, id);
        wrapper.set(UserEcologyHatchRecords::getIsSettleDirectThrustIncome, ecologyHatchDirectThrustIncomeType);
        return update(new UserEcologyHatchRecords(), wrapper);
    }


    public Boolean getBooleanByStatusAndUserId(Long userId, UserEcologyHatchRecordsStatus status) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getUserId, userId);
        wrapper.eq(UserEcologyHatchRecords::getStatus, status);
        return count(wrapper) > 0;
    }
    public Boolean getBooleanByStatusAndUserIdPoints(Long userId, UserEcologyHatchRecordsStatus status,Long hatchCollectionId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getUserId, userId);
        wrapper.eq(UserEcologyHatchRecords::getStatus, status);
        wrapper.eq(UserEcologyHatchRecords::getCollectionId, hatchCollectionId);
        return count(wrapper) > 0;
    }

    public List<UserEcologyHatchRecords> getUserEcologyHatchRecordsByCollectionIdPoints(UserEcologyHatchRecordsStatus status,Long hatchCollectionId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getStatus, status);
        wrapper.eq(UserEcologyHatchRecords::getCollectionId, hatchCollectionId);
        return list(wrapper);
    }

    public boolean getBooleanByStatusAndUserIdAndCollectionIds(Long userId, List<Long> ecologyHatchcollectionIds, UserEcologyHatchRecordsStatus status) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getUserId, userId);
        wrapper.eq(UserEcologyHatchRecords::getStatus, status);
        wrapper.in(UserEcologyHatchRecords::getCollectionId, ecologyHatchcollectionIds);
        return count(wrapper) > 0;
    }

    public boolean getBooleanByStatusAndUserIdAndCollectionIdsPoints(Long userId, Long ecologyHatchCollectionId, UserEcologyHatchRecordsStatus status) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getUserId, userId);
        wrapper.eq(UserEcologyHatchRecords::getStatus, status);
        wrapper.eq(UserEcologyHatchRecords::getCollectionId, ecologyHatchCollectionId);
        return count(wrapper) > 0;
    }


    public List<Long> getListByUserIdsAndStatusAndGtCount(List<Long> userIds, UserEcologyHatchRecordsStatus status, int count) {
        return baseMapper.getListByUserIdsAndStatusAndGtCount(userIds, status.getCode(), count);
    }

    public List<Long> getListByUserIdsAndStatusAndGtCountAndCollectionId(List<Long> userIds, UserEcologyHatchRecordsStatus status, int count,Long hatchCollectionId) {
        return baseMapper.getListByUserIdsAndStatusAndGtCountAndCollectionId(userIds, status.getCode(), count,hatchCollectionId);
    }


    public BigDecimal getSumPriceByUserIdListAndDay(List<Long> userIds, Integer day) {
        return baseMapper.getSumPriceByUserIdListAndDay(userIds, day);
    }

    public BigDecimal getHatchCountByUserIdListAndDayAndCollectionId(List<Long> userIds, Integer day,Long hatchCollectionId) {
        return baseMapper.getHatchCountByUserIdListAndDayAndCollectionId(userIds, day,hatchCollectionId);
    }

    public BigDecimal getSumPriceByUserIdListAndDayAndCollectionIds(List<Long> userIds, List<Long> collectionIds, int days) {
        if (days == 365) {
            return baseMapper.getSumPriceByUserIdListAndDayAndCollectionIds(userIds, collectionIds, days);
        } else {
            DateTime beginOfWeek = DateUtil.beginOfWeek(DateUtil.lastWeek());
            DateTime endOfWeek = DateUtil.endOfWeek(DateUtil.lastWeek());
            return baseMapper.getSumPriceByUserIdListAndLastWeekAndCollectionIds(userIds, collectionIds, beginOfWeek, endOfWeek);
        }
    }

    public BigDecimal getSumPriceByUserIdListAndLastWeek(List<Long> userIds) {
        DateTime beginOfWeek = DateUtil.beginOfWeek(DateUtil.lastWeek());
        DateTime endOfWeek = DateUtil.endOfWeek(DateUtil.lastWeek());

        return baseMapper.getSumPriceByUserIdListAndLastWeek(userIds, beginOfWeek, endOfWeek);
    }

    public BigDecimal getSumPriceByUserIdListAndLastWeekAndCollectionId(List<Long> userIds,Long collectionId) {
        DateTime beginOfWeek = DateUtil.beginOfWeek(DateUtil.lastWeek());
        DateTime endOfWeek = DateUtil.endOfWeek(DateUtil.lastWeek());

        return baseMapper.getSumPriceByUserIdListAndLastWeekAndCollectionId(userIds, beginOfWeek, endOfWeek,collectionId);
    }


    public int getCountByUserIdsAndStatusAndDay(List<Long> userIds, UserEcologyHatchRecordsStatus status, Integer day) {
        return baseMapper.getCountByUserIdsAndStatusAndDay(userIds, status.getCode(), day).size();
    }
    public int getCountByUserIdsAndStatusAndDayAndCollectionId(List<Long> userIds, UserEcologyHatchRecordsStatus status, Integer day,Long hatchCollectionId) {
        return baseMapper.getCountByUserIdsAndStatusAndDayAndCollectionId(userIds, status.getCode(), day,hatchCollectionId);
    }

    public int getCountByUserIdsAndStatusAndLastWeek(List<Long> userIds, UserEcologyHatchRecordsStatus status) {
        DateTime beginOfWeek = DateUtil.beginOfWeek(DateUtil.lastWeek());
        DateTime endOfWeek = DateUtil.endOfWeek(DateUtil.lastWeek());

        return baseMapper.getCountByUserIdsAndStatusAndLastWeek(userIds, status.getCode(), beginOfWeek, endOfWeek).size();
    }

    public int getCountByUserIdsAndStatusAndLastWeekAndCollectionId(List<Long> userIds, UserEcologyHatchRecordsStatus status,Long hatchCollectionId) {
        DateTime beginOfWeek = DateUtil.beginOfWeek(DateUtil.lastWeek());
        DateTime endOfWeek = DateUtil.endOfWeek(DateUtil.lastWeek());

        return baseMapper.getCountByUserIdsAndStatusAndLastWeekAndCollectionId(userIds, status.getCode(), beginOfWeek, endOfWeek,hatchCollectionId);
    }

    public int getCountByUserIdsAndEcologyHatchcollectionIdsAndStatusAndDay(List<Long> userIds, List<Long> collectionIds, UserEcologyHatchRecordsStatus status, Integer day) {
        if (day.intValue() == 365) {
            return baseMapper.getCountByUserIdsAndEcologyHatchcollectionIdsAndStatusAndDay(userIds, collectionIds, status.getCode(), day).size();
        } else {
            DateTime beginOfWeek = DateUtil.beginOfWeek(DateUtil.lastWeek());
            DateTime endOfWeek = DateUtil.endOfWeek(DateUtil.lastWeek());

            return baseMapper.getCountByUserIdsAndEcologyHatchcollectionIdsAndStatusAndLastWeek(userIds, collectionIds, status.getCode(), beginOfWeek, endOfWeek).size();
        }
    }

    public int getCountByUserIdsAndEcologyHatchCollectionIdsAndStatusAndDayPoints(List<Long> userIds, Long collectionId, UserEcologyHatchRecordsStatus status, Integer day) {
        if (day.intValue() == 30) {
            return baseMapper.getCountByUserIdsAndEcologyHatchCollectionIdsAndStatusAndDayPoints(userIds, collectionId, status.getCode(), day).size();
        } else {
            DateTime beginOfWeek = DateUtil.beginOfWeek(DateUtil.lastWeek());
            DateTime endOfWeek = DateUtil.endOfWeek(DateUtil.lastWeek());
            return baseMapper.getCountByUserIdsAndEcologyHatchCollectionIdsAndStatusAndLastWeekPoints(userIds, collectionId, status.getCode(), beginOfWeek, endOfWeek).size();
        }
    }


    public List<Long> recentlyDaySmelt(List<Long> userIds, UserEcologyHatchRecordsStatus status, int day,Long collectionId) {
        return baseMapper.recentlyDaySmelt(userIds, status.getCode(), day,collectionId);
    }

    public List<Long> recentlyDaySmeltLastWeek(List<Long> userIds, UserEcologyHatchRecordsStatus status,Long collectionId) {
        DateTime beginOfWeek = DateUtil.beginOfWeek(DateUtil.lastWeek());
        DateTime endOfWeek = DateUtil.endOfWeek(DateUtil.lastWeek());
        return baseMapper.recentlyDaySmeltLastWeek(userIds, status.getCode(), beginOfWeek, endOfWeek,collectionId);
    }


    /**
     * 总质押人数
     *
     * @return
     */
    public Integer getSumEcologyUserCount() {
        return baseMapper.getSumEcologyUserCount();
    }

    public List<Map<String, String>> getSumCollectionEcologyCount() {
        return baseMapper.getSumCollectionEcologyCount();
    }

    /**
     * 按日期质押人数
     *
     * @return
     */
    public Integer getSumEcologyUserCountByDate(Date startTime, Date endTime) {
        return baseMapper.getSumEcologyUserCountByDate(startTime, endTime);
    }

    public BigDecimal getSumEcologyPoints() {
        return baseMapper.getSumEcologyPoints();
    }

    public BigDecimal getYesterDaySumEcologyPoints() {
        return baseMapper.getYesterDaySumEcologyPoints();
    }

    public BigDecimal getPutIntoFuelByStartTimeAndEndTime(Date startTime, Date endTime) {
        return baseMapper.getPutIntoFuelByStartTimeAndEndTime(startTime, endTime);
    }

    public Page<AdminUserEcologyHatchRcordsVO> userRecords(Long daoUserId, Long daoId, Long collectionId, String userTel, String startTime, String endTime, Integer pageNo, Integer pageSize, String methodName) {
        return baseMapper.userRecords(new Page<>(pageNo, pageSize), daoUserId, collectionId, userTel, startTime, endTime, methodName);
    }

    public Page<AdminMetaUserEcologyHatchRcordsVO> adminUserRecords(String collectionName, String userTel, String startTime, String endTime, Integer pageNo, Integer pageSize, String methodName) {
        return baseMapper.adminUserRecords(new Page<>(pageNo, pageSize), collectionName, userTel, startTime, endTime, methodName);
    }

    public List<AdminUserEcologyHatchRcordsDetailsVO> userRecordsDetails(Long id) {
        return baseMapper.userRecordsDetails(id);
    }

    public List<SumEcologyPointsGroupUserDTO> getSumEcologyPointsGroupUserId() {
        return baseMapper.getSumEcologyPointsGroupUserId();
    }

    public Integer getcountByCollectionId(Long collectionId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getCollectionId, collectionId);
        return count(wrapper);
    }

    public List<EcologyGetDestructionDTO> getCountByCollectionIdWithDestruction(Long collectionId) {
        return baseMapper.getCountByCollectionIdWithDestruction(collectionId);
    }

    public Integer getSumUserCount(Long collectionId) {
        return baseMapper.getSumUserCount(collectionId);
    }

    public BigDecimal getSumEcologyPointsByCollectionId(Long collectionId) {
        return baseMapper.getSumEcologyPointsByCollectionId(collectionId);
    }

    public Page<AdminShareProfitCollectDetailsVO> getPageByUserTelAndTime(Long collectionId, String userTel, Date startTime, Date endTime, Integer pageNo, Integer pageSize) {
        return baseMapper.getPageByUserTelAndTime(new Page<>(pageNo, pageSize), collectionId, userTel, startTime, endTime);
    }

    public boolean updateEffectivePerformanceById(Long id, BigDecimal platformEffectivePerformance, BigDecimal daoEffectivePerformance) {
        LambdaUpdateWrapper<UserEcologyHatchRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getId, id);
        wrapper.set(UserEcologyHatchRecords::getPlatformEffectivePerformance, platformEffectivePerformance);
        wrapper.set(UserEcologyHatchRecords::getDaoEffectivePerformance, daoEffectivePerformance);
        return update(new UserEcologyHatchRecords(), wrapper);
    }


    public BigDecimal getSumPriceByUserIdAndCollectionIdAndTime(Long daoUserId, Long collectionId, DateTime toDay, Long serviceCenterUserId, Date daoOnlineTime) {
        return baseMapper.getSumPriceByUserIdAndCollectionIdAndTime(daoUserId, collectionId, toDay, serviceCenterUserId, daoOnlineTime);
    }


    public boolean updateIsSettleDivideIntoById(Long id, Boolean isSettleDivideInto, Long userInDaoId) {
        LambdaUpdateWrapper<UserEcologyHatchRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getId, id);
        wrapper.set(UserEcologyHatchRecords::getIsSettleDivideInto, isSettleDivideInto);
        if (Objects.nonNull(userInDaoId)) {
            wrapper.set(UserEcologyHatchRecords::getUserInDaoId, userInDaoId);
        }
        return update(new UserEcologyHatchRecords(), wrapper);
    }

    public List<UserEcologyHatchRecords> getListByisSettleDivideIntoAndTime(Boolean isSettleDivideInto) {
        return baseMapper.getListByisSettleDivideIntoAndTime(isSettleDivideInto);
    }

    public List<UserEcologyHatchRecords> getListByLtTime(DateTime dateTime) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.lt(UserEcologyHatchRecords::getCreateTime, dateTime);
        return list(wrapper);
    }

    public List<UserEcologyHatchRecords> getListByGeTime(DateTime dateTime) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.ge(UserEcologyHatchRecords::getCreateTime, dateTime);
        return list(wrapper);
    }

    public List<AdminUserEcologyHatchRcordsVO> userRecordsExport(Long daoId, String collectionName, String userTel, String startTime, String endTime) {
        return baseMapper.userRecordsExport(daoId, collectionName, userTel, startTime, endTime);
    }

    public Integer getCountByStatusAndUserIdAndId(Long userId, UserEcologyHatchRecordsStatus status, Long ecologyHatchId) {
        return baseMapper.getCountByStatusAndUserIdAndId(userId, status.getCode(), ecologyHatchId);
    }

    public List<Integer> getCountByStatusAndJuniorUserIdsAndId(Long recommendUserId, UserEcologyHatchRecordsStatus status, Long id) {
        return baseMapper.getCountByStatusAndJuniorUserIdsAndId(recommendUserId, status.getCode(), id);
    }

    public int getCountByStatusAndUserIdAndCollectionId(Long userId, UserEcologyHatchRecordsStatus status, Long collectionId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getUserId, userId);
        wrapper.eq(UserEcologyHatchRecords::getStatus, status);
        wrapper.eq(UserEcologyHatchRecords::getCollectionId, collectionId);
        return count(wrapper);
    }

    public int getNewCountByStatusAndUserIdAndCollectionId(Long userId, Long collectionId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getUserId, userId);
        wrapper.eq(UserEcologyHatchRecords::getCollectionId, collectionId);
        return count(wrapper);
    }

    public Integer getSumHatchCountByUserId(Long userId) {
        return baseMapper.getSumHatchCountByUserId(userId);
    }

    /**
     * 获取用户熔炼总额(取发行价)
     *
     * @param usersWhoExcludeUsersFromCommunityStudiosAndCityServiceCenters
     * @return
     */
    public BigDecimal getUserIdsSmeltMarketValue(List<Long> usersWhoExcludeUsersFromCommunityStudiosAndCityServiceCenters) {
        return baseMapper.getUserIdsSmeltMarketValue(usersWhoExcludeUsersFromCommunityStudiosAndCityServiceCenters);
    }

    public List<UserHatchCountDTO> getListByGroupUserIdAndCollectionId(Long collectionId) {
        return baseMapper.getListByGroupUserIdAndCollectionId(collectionId);
    }

    public AdminTeamHatchDataVO getPageTeamHatchData(Long daoUserId, Long collectionId, Long userId, Date startTime, Date endTime) {
        return baseMapper.getPageTeamHatchData(daoUserId, collectionId, userId, startTime, endTime);
    }

    public Integer getSumHatchCountByCollectionId(Long collectionId) {
        return baseMapper.getSumHatchCountByCollectionId(collectionId);
    }

    public Integer getHatchUserCountByCollectionId(Long collectionId) {
        return baseMapper.getHatchUserCountByCollectionId(collectionId);
    }

    public List<UserEcologyHatchRecords> getListByIsSettleDivideInto(Boolean isSettleDivideInto) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getIsSettleDivideInto, isSettleDivideInto);
        return list(wrapper);
    }

    public List<UserEcologyHatchRecords> getListByPlatformEffectiveAndDaoEffective() {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getPlatformEffectivePerformance, BigDecimal.ZERO);
        wrapper.eq(UserEcologyHatchRecords::getDaoEffectivePerformance, BigDecimal.ZERO);
        return list(wrapper);
    }

    public BigDecimal getSumMarketValueLessThan(Integer min, Integer max) {
        return baseMapper.getSumMarketValueLessThan(min, max);

    }

    public BigDecimal getSumUserCountLessThan(Integer min, Integer max) {
        return baseMapper.getSumUserCountLessThan(min, max);
    }

    public Boolean updateStatusById(Long id) {
        LambdaUpdateWrapper<UserEcologyHatchRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getId, id);
        wrapper.eq(UserEcologyHatchRecords::getStatus, UserEcologyHatchRecordsStatus.UNDER_WAY);
        wrapper.set(UserEcologyHatchRecords::getStatus, UserEcologyHatchRecordsStatus.ALREADY_ENDED);
        return update(new UserEcologyHatchRecords(), wrapper);
    }

    public List<UserEcologyHatchRecords> getListByCollectionId(Long userId, Long collectionId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getUserId, userId);
        wrapper.eq(UserEcologyHatchRecords::getCollectionId, collectionId);
        return list(wrapper);
    }

    /**
     * 获取熔炼配置下的所有熔炼记录
     *
     * @param ecologyHatchId
     * @return
     */
    public List<UserEcologyHatchRecords> getList(Long ecologyHatchId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getEcologyHatchId, ecologyHatchId);
        wrapper.orderByDesc(UserEcologyHatchRecords::getId);
        return list(wrapper);
    }

    public List<UserEcologyHatchRecords> getListByIds(List<Long> ids) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(UserEcologyHatchRecords::getId, ids);
        return list(wrapper);
    }

    /**
     * 修改熔炼记录的熔炼方法
     *
     * @param ecologyHatchId
     * @return
     */
    public Boolean updateMethodByEcologyHatchId(Long ecologyHatchId, Long methodId) {
        LambdaUpdateWrapper<UserEcologyHatchRecords> wrapper = new LambdaUpdateWrapper<>();
        wrapper.eq(UserEcologyHatchRecords::getEcologyHatchId, ecologyHatchId);
        wrapper.eq(UserEcologyHatchRecords::getMethodId, 0);
        wrapper.set(UserEcologyHatchRecords::getMethodId, methodId);
        return update(new UserEcologyHatchRecords(), wrapper);
    }

    public BigDecimal getSmeltingValue(Long userId, Date startTime, Date endTime) {
        return baseMapper.getSmeltingValue(userId, startTime, endTime);
    }

    /**
     * 获取已熔炼数量
     *
     * @param ecologyHatchId
     * @return
     */
    public Integer getHatchCountByEcologyHatchId(Long ecologyHatchId) {
        return baseMapper.getHatchCountByEcologyHatchId(ecologyHatchId);
    }

    public List<HatchCountPageVO> getHatchCountVO(Long userCreatorId) {
        return baseMapper.getHatchCountVO(userCreatorId);
    }

    /**
     * 获取市值管理所需平台用户熔炼的份数
     */
    public Integer userInPlatformNum(Long ecologyHatchId, Long platformDaoId) {
        return baseMapper.userInPlatformNum(ecologyHatchId, platformDaoId);
    }


    /**
     * 获取市值管理品牌熔炼的份数
     */
    public Integer userInDaoNum(Long ecologyHatchId, List<Long> daoIds) {
        return baseMapper.userInDaoNum(ecologyHatchId, daoIds);
    }

    public BigDecimal getUserWorkRoomExcludeExchequerList(Long userId, Date startTime, Date endTime, List<Long> collectionIdList) {
        return baseMapper.getUserWorkRoomExcludeExchequerList(userId, startTime, endTime, collectionIdList);
    }

    public BigDecimal getUserCityServerExcludeExchequerList(Long userId, Date startTime, Date endTime, List<Long> collectionIdList) {
        return baseMapper.getUserCityServerExcludeExchequerList(userId, startTime, endTime, collectionIdList);
    }

    public List<UserEcologyHatchRecords> getScriptNeedList() {
        return baseMapper.getScriptNeedList();
    }


    public List<UserEcologyHatchRecords> getScriptNeedAllList() {
        return baseMapper.getScriptNeedAllList();
    }


    public Integer getUserSum(Long userId,Long collectionId) {
        return baseMapper.getUserSum(userId,collectionId);
    }

    public Integer getLimitsTheUserSum(Long userId) {
        return baseMapper.getLimitsTheUserSum(userId);
    }

    public Integer getAllUserSum(Long userId) {
        return baseMapper.getAllUserSum(userId);
    }

    public List<UserEcologyHatchRecords> getAllByEcologyHatchIdList(Long ecologyHatchId) {
        return baseMapper.getAllByEcologyHatchIdList(ecologyHatchId);
    }

    public List<UserEcologyHatchRecords> otherScriptList() {
        return baseMapper.otherScriptList();
    }

    public List<UserEcologyHatchRecords> scriptList() {
        return baseMapper.scriptList();
    }

    public void updateScriptList() {
        baseMapper.updateScriptList();
    }

    public List<UserEcologyHatchRecords> listByUserId(List<Long> userId) {
        LambdaQueryWrapper<UserEcologyHatchRecords> wrapper = new LambdaQueryWrapper<>();
        wrapper.in(UserEcologyHatchRecords::getUserId, userId);
        return baseMapper.selectList(wrapper);
    }

    public List<EcologySmeltVO> ecologySmeltCount(Long daoId, Date startTime, Date endTime) {
        return baseMapper.ecologySmeltCount(daoId, startTime, endTime);
    }

    /**
     * 用户总投入
     * @param pointsId
     * @param startTime
     * @param endTime
     * @return
     */
    public BigDecimal getDynamicRewardAmount(Long pointsId, Date startTime, Date endTime) {
        return baseMapper.getDynamicRewardAmount(pointsId, startTime, endTime);
    }


    public List<Long> getListByUserIdsAndCollectionIdAndStatusAndGtCount(List<Long> juniorUserIds, UserEcologyHatchRecordsStatus userEcologyHatchRecordsStatus, int count, Long hatchCollectionId) {
        return baseMapper.getListByUserIdsAndCollectionIdAndStatusAndGtCount(juniorUserIds,userEcologyHatchRecordsStatus.getCode(),count,hatchCollectionId);
    }

    public List<UserEcologyDTO> getBooleanByStatusAndUserIdListPoints(List<Long> userIds, UserEcologyHatchRecordsStatus userEcologyHatchRecordsStatus, Long hatchCollectionId) {
        return baseMapper.getBooleanByStatusAndUserIdListPoints(userIds,userEcologyHatchRecordsStatus.getCode(),hatchCollectionId);
    }

    public List<Long> ecologyIngServiceCenter(List<Long> allUserCityServerCentreUserId, UserEcologyHatchRecordsStatus userEcologyHatchRecordsStatus, Long collectionId) {
        return baseMapper.ecologyIngServiceCenter(allUserCityServerCentreUserId,userEcologyHatchRecordsStatus.getCode(),collectionId);
    }
}